﻿namespace ConsoleApp2
{
    //2 匿名类型
    /*   匿名类型（Anonymous Types）是一种方便的方式，
     *   允许你创建临时的只读对象，其中包含一组具有不同数据类型的属性*/
    internal class Program
    {
        static void Main(string[] args)
        {
            var person = new { Name = "shang", Age = 23 }; // 定义一个匿名类型

            Console.WriteLine($"Name: {person.Name}, Age: {person.Age}");

            Console.WriteLine("**********");
            
            var people = new[]
        {
            new { Name = "shang", Age = 22 },
            new { Name = "shou", Age = 34 },
            new { Name = "lai", Age = 21 }
        };

            var youngPeople = from son in people
                              where son.Age < 30
                              select son.Name;

            foreach (var name in youngPeople)
            {
                Console.WriteLine(name);
            }

        }



    }
}